package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CommunitySecurity;
import com.ruoyi.system.service.ICommunitySecurityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社区安防
Controller
 * 
 * @author ruoyi
 * @date 2021-06-29
 */
@RestController
@RequestMapping("/system/security")
public class CommunitySecurityController extends BaseController
{
    @Autowired
    private ICommunitySecurityService communitySecurityService;

    /**
     * 查询社区安防
列表
     */
    @PreAuthorize("@ss.hasPermi('system:security:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommunitySecurity communitySecurity)
    {
        startPage();
        List<CommunitySecurity> list = communitySecurityService.selectCommunitySecurityList(communitySecurity);
        return getDataTable(list);
    }

    /**
     * 导出社区安防
列表
     */
    @PreAuthorize("@ss.hasPermi('system:security:export')")
    @Log(title = "社区安防", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CommunitySecurity communitySecurity)
    {
        List<CommunitySecurity> list = communitySecurityService.selectCommunitySecurityList(communitySecurity);
        ExcelUtil<CommunitySecurity> util = new ExcelUtil<CommunitySecurity>(CommunitySecurity.class);
        return util.exportExcel(list, "security");
    }

    /**
     * 获取社区安防
详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:security:query')")
    @GetMapping(value = "/{csId}")
    public AjaxResult getInfo(@PathVariable("csId") Long csId)
    {
        return AjaxResult.success(communitySecurityService.selectCommunitySecurityById(csId));
    }

    /**
     * 新增社区安防

     */
    @PreAuthorize("@ss.hasPermi('system:security:add')")
    @Log(title = "社区安防", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommunitySecurity communitySecurity)
    {
        return toAjax(communitySecurityService.insertCommunitySecurity(communitySecurity));
    }

    /**
     * 修改社区安防

     */
    @PreAuthorize("@ss.hasPermi('system:security:edit')")
    @Log(title = "社区安防", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommunitySecurity communitySecurity)
    {
        return toAjax(communitySecurityService.updateCommunitySecurity(communitySecurity));
    }

    /**
     * 删除社区安防

     */
    @PreAuthorize("@ss.hasPermi('system:security:remove')")
    @Log(title = "社区安防", businessType = BusinessType.DELETE)
	@DeleteMapping("/{csIds}")
    public AjaxResult remove(@PathVariable Long[] csIds)
    {
        return toAjax(communitySecurityService.deleteCommunitySecurityByIds(csIds));
    }
}
